package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import persistence.QuoteEngineDAO;
import persistence.QuoteVO;

/**
 * Servlet implementation class getquotes
 */
public class quotes extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public quotes() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);
	}

	private void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
		QuoteEngineDAO dao = new QuoteEngineDAO();
		QuoteVO vo = new QuoteVO();

		if(request.getParameter("action").equals("star")){
			vo.setStar(Integer.parseInt(request.getParameter("star")));
			vo.setStock(request.getParameter("stock"));
			dao.update(vo);
		}
	}

}
